<!--
Copyright 2003 Cordys R&D B.V. 

This file is part of the Cordys SAP Connector. 

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
 Project  : Cordys BAC
 File Name : listkeystores.htm
 Description : This file lists all the keystores on the right side.
-->
<html xmlns:eibus onselect= "Title()">
<head>
       <link rel="stylesheet" href="/cordys/wcp/style/behaviors.css"/>
       <title></title>
	   <script language="javascript">
		/*Function Name : Title
			No Parametars
			Scope : It gets the application definition and sets the title of the page.*/
	   function Title()
	   {
			applicationDef=window.event.applicationDefinition
			window.application.container.setTitle(applicationDef.selectSingleNode(".//description").text,"BAC for SAP R/3");
	   }		
		/*Function Name : initialize
			No Parametars
			Scope : It gets all the keystores and shows them in a table in the UI.*/
	   function initialize()
	   {
			var newRow;
			var count=0,index=0;
			var keyStoreArray=new Array();
			var env=new ActiveXObject("Microsoft.XMLDOM");
			var cloneGetKeyStores = getKeyStoreXML.XMLDocument.cloneNode(true);
			cloneGetKeyStores.selectSingleNode("SOAP:Envelope/SOAP:Body/GetSoapProcessors/dn").text = application.organization;
			digetEntries.request=cloneGetKeyStores;
			digetEntries.reset();
			var keyStoreList=digetEntries.data.getElementsByTagName("bussoapprocessorconfiguration");
			for(var i=0;i<keyStoreList.length;i++)
			{
				env.loadXML(keyStoreList[i].selectSingleNode(".//string").text);
				var implementation=env.selectSingleNode(".//configurations/configuration").getAttribute("implementation");
				if(implementation == null) continue;
				if( implementation=="com.eibus.applicationconnector.sap.SAPMapper")
				{
					var envNode = env.selectSingleNode(".//env");
					if(envNode == null) continue;
					var keyStoreLocation = envNode.getAttribute("keyStoreLoc");
					if(keyStoreLocation == null) continue;
					for(var j=0;j<keyStoreLocation.length;j++)
					{
						character=keyStoreLocation.charAt(j);
						if(character=="\\" || character=="//")
						{
							index=j;
						}
					}
					if(index>0)
					{
						LDAPkeystorePath=keyStoreLocation.substring(index+1,env.selectSingleNode(".//env").getAttribute("keyStoreLoc").length);
					}
					//var keyPath=env.selectSingleNode(".//env").getAttribute("keyStoreLoc");
					var flag=0;
					for(var k=0;k<keyStoreArray.length;k++)
					{
						if(keyStoreLocation.toUpperCase()==keyStoreArray[k].toUpperCase())
						{
							flag=1;
							break;
						}
					}
					if(flag==0)
					{
						keyStoreArray[count++]=keyStoreLocation;						
						LDAPkeystorePath=keyStoreLocation.substring(index+1,keyStoreLocation.length);
						newRow=keyStoreTable.insertRow();
						var	newTD = newRow.insertCell();
						newTD.innerHTML="<tr  ><td >&nbsp;"+LDAPkeystorePath+"</td></tr>";						
					}
				}
			}
	   }
	/*Function Name : showGatewayError
			Scope : This is to hide the gateway error and show only the fault information.*/
		function showGatewayError()
		{
			window.event.errorText = false;
			alert("Error occured in the gateway. Please contact the administrator to find the details");				
		}		
		/*Function Name : showFault
			Scope : This is to hide the soapfaults and show only the fault information.*/
		function showFault()
		{
			window.event.errorText = false;
			alert(window.event.errorText);
			
		}
	   </script>
	</head>
	<eibus:dataisland
		 id="digetEntries"
		 request="getEntries.XMLDocument"
		 automatic = "false"
		 async="false"
		 onsoapfault = "showFault()"
		ongatewayerror = "showGatewayError()"/>
	<xml id="getKeyStoreXML">
	<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
	    <SOAP:Body>
	        <GetSoapProcessors xmlns="http://schemas.cordys.com/1.0/ldap">
	            <dn></dn>        
	        </GetSoapProcessors>
	    </SOAP:Body>
	</SOAP:Envelope>
	</xml>
<body onload="initialize()">
<br>
<br>
	<center>
	<div class="mediumdark"  align=center style="width:70%;border:0px solid gray">
	<table id="keyStoreTable" class="grid"  style="width:100%" cellspacing = '1' cellpadding = '0'   >
		<thead>
			<tr class="mediumdark" >
				<td >&nbsp;Key Stores</td>
			</tr>
		</thead>
		<tbody class="light">

		</tbody>
	</table>
	</div>
	</center>
</body>
</html>